﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Imaginecup.util.resourceMan;
using Microsoft.Xna.Framework;

namespace Imaginecup.gameState.malaria.manager
{
    public class LifeMan
    {
        private int m_LifeCount;

        private static LifeMan m_Life = null;

        private LifeMan(){}

        public static LifeMan GetLifeMan()
        {
            if( m_Life == null )
            {
                m_Life = new LifeMan();
            }
            return m_Life;
        }

        public void DecreaseLife()
        {
            m_LifeCount--;
            if (m_LifeCount < 0)
                m_LifeCount = 0;
        }

        public int GetLifeCount()
        {
            return m_LifeCount;
        }

        public void Release()
        {
            m_Life = null;
        }

        public void SetLife(int lifeCount)
        {
            m_LifeCount = lifeCount;
        }

        public void Draw(SpriteBatch sb)
        {
            Texture2D texture = ResourceMan.GetResourceMan().GetTexture("Life");
            Rectangle rectangle = new Rectangle();

            rectangle.X = 500;
            rectangle.Y = 30;
            rectangle.Width = 50;
            rectangle.Height = 50;

            sb.Begin();


            for (int i = 0; i < m_LifeCount; i++ )
            {
                sb.Draw(texture, rectangle, Color.White);                
                rectangle.X += (rectangle.Width + 10) ;
            }
            
            sb.End();
        }
    }
}
